import java.util.Scanner;

public class Practice2 {
    //https://www.nowcoder.com/questionTerminal/c55f4f15cc3f4ff0adede7f9c69fa0c1
    //贪心 + 位运算(位运算这个我是第一次知道)
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = Integer.MIN_VALUE;
        int[] arr = new int[n];
        for(int i = 0;i < n;i++){
            arr[i] = sc.nextInt();
            max = Math.max(max,arr[i]);
        }
        boolean flag = true;
        for(int i = 0;i < n;i++){
            if(max % arr[i] != 0){
                System.out.println("NO");
                flag = false;
                break;
            }
            int x = max / arr[i];
            if((x & (x - 1)) != 0){
                //判断是否是2的n次方的倍数
                System.out.println("NO");
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("YES");
        }


















    }
}